<?php 
// Link to list of catalogs
$catalogs = '<a href="DBList.php">Catalogs</a>';
// Link to the currrent catalog
$sql = 'SELECT dbName FROM `databases` WHERE `dbID`= ? ';
$dbName = urlencode($dbRead->fetchOne($sql,$_GET['dbId']));
//$path=$catalogs.'<a href="DBMain.php?dbId='.$_GET['dbId'].'&amp;name='.$dbName.'">'.$dbName.'</a>-->';
$path="";
// Calculate the link for all the ansestors
$id = (isset($_GET['id']) ? $_GET['id'] : 0);
while ($id!=0){
	$sql = 'SELECT parentId FROM `containers` WHERE `Id`= ? ';
	$id = $dbRead->fetchOne($sql,$id); // id now points to parent
	if ($id!=0){
		$sql = 'SELECT name FROM `containers` WHERE `id`= ? ';
		$name = urlencode($dbRead->fetchOne($sql,$id));
		$parentURL = "-->".'<a href="DBMain.php?id='.$id.'&amp;name='.$name.'&amp;dbId='.$_GET['dbId'].'">'.urldecode($name).'</a>';
	} else {
		$parentURL = "-->".'<a href="DBMain.php?dbId='.$_GET['dbId'].'&amp;name='.$dbName.'">'.urldecode($dbName).'</a>';
	}
	$path = $parentURL.$path;
}
$path = $catalogs.$path;

